<?php

namespace Home\Controller;

use Think\Controller;

class ModuleLookController extends Controller
{
    public function index()
    {
        $this->assign('username', session('user_name'));
        $this->assign('form', session('form'));
        $this->display();
    }
    //查看土建专业模块
    public function tujian()
    {
        $module = M('module');
        $discount = M('discount');
        $resultModule = $module->where(array('type' => '土建专业'))->select();
        $this->assign('username', session('user_name'));
        $this->assign('form', session('form'));
        $this->assign('moduleData', $resultModule);
        $this->display();
    }
    //查看铁塔专业模块
    public function tieta()
    {
        $module = M('module');
        $resultModule = $module->where(array('type' => '铁塔专业'))->select();
        $this->assign('username', session('user_name'));
        $this->assign('form', session('form'));
        $this->assign('moduleData', $resultModule);
        $this->display();
    }
    //查看交流专业模块
    public function jiaoliu()
    {
        $module = M('module');
        $resultModule = $module->where(array('type' => '交流专业'))->select();
        $this->assign('username', session('user_name'));
        $this->assign('form', session('form'));
        $this->assign('moduleData', $resultModule);
        $this->display();
    }
    //查看配套专业模块
    public function peitao()
    {
        $module = M('module');
        $resultModule = $module->where(array('type' => '配套专业'))->select();
        $this->assign('username', session('user_name'));
        $this->assign('form', session('form'));
        $this->assign('moduleData', $resultModule);
        $this->display();
    }
    //查看模块对于优惠率
    public function discount()
    {
        $discount = M('discount');
        $map = array(
            'class' => I('post.class'),
            'mid' => I('post.number'),
            'uid' => session(C('USER_AUTH_KEY')),
            'type' => I('post.type'),
        );
        $data = $discount->where($map)->select();
        if (is_array($data)) {
            echo json_encode(array('code' => 'ok', 'msg' => '成功', 'data' => $data));
        } else {
            echo json_encode(array('code' => 'fial', 'msg' => '失败', 'data' => ''));
        }
    }
}
